home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
oleo130s.zip
/
OLEO130S.TAR
/
oleo-1.3
/
funcs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-27
|
3KB
|
141 lines
/* Copyright (C) 1993 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this software; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* This file contains descriptions of all the interactive functions
* built into oleo.
*/
#include "global.h"
#include "cmd.h"
#include "key.h"
#include "io-term.h"
#include "basic.h"
#include "format.h"
#include "print.h"
#include "font.h"
#include "io-x11.h"
#include "io-edit.h"
#include "regions.h"
#include "help.h"
#include "window.h"
#include "font.h"
#include "graph.h"
#include "lists.h"
/* This include builds the function table, doc strings, and FUNC_ARGS strings.
*/
#include "defuns.h"
/* Returns 0 if the function is found.
* Also returns (through parameters) the vector and cmd_func.
* The output parameters can be NULL.
*/
#ifdef __STDC__
int
find_function (int * vec_out, struct cmd_func ** cmd_out, char * name, int len)
#else
int
find_function (vec_out, cmd_out, name, len)
int * vec_out;
struct cmd_func ** cmd_out;
char * name;
int len;
#endif
{
int vector;
struct cmd_func * cmd;
for (vector = 0; vector < num_funcs; vector++)
for (cmd = &the_funcs[vector][0]; cmd->func_name; cmd++)
if (!(strincmp (name, cmd->func_name, len) || cmd->func_name[len]))
{
if (vec_out)
*vec_out = vector;
if (cmd_out)
*cmd_out = cmd;
return 0;
}
return 1;
}
static struct cmd_func * named_macro_strings = 0;
static int num_named_macro_strings = 0;
static int named_macro_vec;
#ifdef __STDC__
void
init_named_macro_strings (void)
#else
void
init_named_macro_strings ()
#endif
{
named_macro_strings =
(struct cmd_func *) ck_malloc (sizeof (struct cmd_func));
bzero (named_macro_strings, sizeof (struct cmd_func));
named_macro_vec = add_usr_cmds (named_macro_strings);
}
#ifdef __STDC__
void
name_macro_string (char * name, char * str)
#else
void
name_macro_string (name, str)
char * name;
char * str;
#endif
{
int i = num_named_macro_strings;
++num_named_macro_strings;
named_macro_strings =
((struct cmd_func *)
ck_realloc (named_macro_strings,
((1 + num_named_macro_strings) * sizeof (struct cmd_func))));
the_funcs [named_macro_vec] = named_macro_strings;
bzero (named_macro_strings + num_named_macro_strings,
sizeof (struct cmd_func));
{
struct cmd_func * cf = &named_macro_strings [i];
cf->func_name = ck_savestr (name);
cf->func_func = run_string_as_macro;
cf->init_code = 0;
{
struct info_buffer * ib = find_or_make_info (name);
clear_info (ib);
print_info (ib, "Equivelent to %s.", str);
cf->func_doc = ib->text;
}
{
int i = 0;
cf->func_args = (char **)ck_malloc (3 * sizeof (char *));
cf->func_args [i++] = mk_sprintf ("=%s", str);
cf->func_args [i++] = "p";
cf->func_args [i++] = 0;
}
}
}